package ctrLayer;

import modelLayer.*;


import static org.junit.Assert.*;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;

/**
 * The test class PersonCtrTest.
 *
 * @author  (your name)
 * @version (a version number or a date)
 */
public class PersonCtrTest
{
    /**
     * Default constructor for test class PersonCtrTest
     */
    public PersonCtrTest()
    {
    }

    /**
     * Sets up the test fixture.
     *
     * Called before every test case method.
     */
    @Before
    public void setUp()
    {
        PersonCtr personCtr = new PersonCtr();
        try
        {
            personCtr.opretPerson(null, null, "a", "b", "c", "d", "e", "f");
        }
        catch (Exception e) {}
    }

    /**
     * Tears down the test fixture.
     *
     * Called after every test case method.
     */
    @After
    public void tearDown()
    {
        PersonCtr personCtr = new PersonCtr();
        try
        {
        personCtr.sletPerson("e");
        }
        catch (Exception e){}
    }
    
    @Test
    public void sletPerson()
    {
        PersonCtr personCtr = new PersonCtr();
        
        assertNotNull(personCtr.findPerson("e"));
        try
        {
        personCtr.sletPerson("e");
        }
        catch (Exception e){}
        assertNull(personCtr.findPerson("e"));
    }

    @Test
    public void findPerson()
    {
        PersonCtr personCtr = new PersonCtr();
        Person p = personCtr.findPerson("e");
        assertNotNull(p);
    }
    
    @Test
    public void CheckOmPersonIkkeErKunde()
    {
        PersonCtr personCtr = new PersonCtr();
        Person p = personCtr.findPerson("e");
        
        assertNull(p.getKunde());
    }
    
    @Test
    public void GoerPersonTilKundeCheckOmPersonErKunde()
    {
        PersonCtr personCtr = new PersonCtr();
        Person p = personCtr.findPerson("e");
        
        assertNull(p.getKunde());
        p.setKunde(new Privat());
        assertNotNull(p.getKunde());
    }
}

